// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '../store' //引入vuex

import topbar from './components/Bar/TopBar' // 导入子组件
import leftsidebar from './components/Bar/LeftSideBar' // 导入子组件
import uploadbar from './components/Bar/UploadBar' // 导入子组件
import DataList from './components/Content/DataList'
import topbar_manage from './components/Bar/TopBar_manage'
import leftsidebar_manage from './components/Bar/LeftSideBar_manage'
import workerlist from './components/Content/Workerlist'
import grouplist from './components/Content/Grouplist'
import addmemberlist from './components/Content/Addmemberlist'
import groupdetaillist from './components/Content/Groupdetaillist'
import UploadBar1 from './components/Bar/UploadBar1'
import TrashDataList from './components/Content/TrashDataList'
import addmemberlistex from './components/Content/Addmemberlistex'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import cookies from 'vue-cookies'
import Axios from 'axios';
Vue.prototype.$axios = Axios;
Vue.prototype.$cookies = cookies; //配置时候prototype.$这里的名字自己定义不是固定是cookie
Vue.config.productionTip = false

Axios.defaults.timeout = 15000; //超时响应
Axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8'; // 配置请求头
Axios.defaults.headers.put['Content-Type'] = 'application/json;charset=utf-8';
Axios.defaults.headers.common['tokenLogin'] = store.state.token;
Axios.defaults.withCredentials = true; // axios 默认不发送cookie，需要全局设置true发送cookie

// 在使用前把token加到请求头里面去
Axios.interceptors.request.use(config => {
    config.headers.common['tokenLogin'] = store.state.token;
    return config;
})

Vue.use(ElementUI);

Vue.component('uploadBar1', UploadBar1)
Vue.component('TrashDataList', TrashDataList)
Vue.component('DataList', DataList)
Vue.component('topbar', topbar)
Vue.component('leftsidebar', leftsidebar)
Vue.component('uploadbar', uploadbar)

Vue.component('topbar_manage', topbar_manage)
Vue.component('leftsidebar_manage', leftsidebar_manage)
Vue.component('workerlist', workerlist)
Vue.component('grouplist', grouplist)
Vue.component('addmemberlist', addmemberlist)
Vue.component('addmemberlistex', addmemberlistex)
Vue.component('groupdetaillist', groupdetaillist)

new Vue({
    el: '#app',
    router,
    store,
    components: {
        App
    },
    template: '<App/>'
})